﻿<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<Rose.Models.AlbumModel>" %>

    
 
    
   
   <div id="createalbum">
    
     <div class="box">
     <a> 标题:</a> 
     <input id="Title" name="Title" type="text" value=""/>
     
     </div>
     <div class="nobox"><a class="laber">权限:</a>
     <a class="info">
      		<input type="radio" name="IsOnlyForFriend" value="0"/>隐私
            <input type="radio" name="IsOnlyForFriend" value="1"/>仅朋友可见
           <input type="radio" name="IsOnlyForFriend" value="2" checked="checked" />公开
           </a> 
      <p><button class="addalbum"></button></p>
     </div>
     
    </div> <!--end of createalbum-->



   
   
   <script type="text/javascript">
       $(document).ready(function () {
           $('.addalbum').click(function () {
               var title = $('#Title').val();
               var isonlyforfriend = $('.nobox').find('input:checked').val();
               alert(title);
               alert(isonlyforfriend);
               $.ajax({
                   type: 'post',
                   url: '/Album/AddAlbum',
                   data: { title: title, isonlyforfriend: isonlyforfriend },
                   success: function (data) {

                       //call back
                       var power = $('div#createalbum input:checked').val();
                       var title = $('div#createalbum input#Title').val();
                       $html = '<div class="album"><div class="albumimage"><p><a id="' + data + '" href="/Content/Images/default.png" rel="prettyPhoto[' + data + ']" title="' + title + '"><img src="/Image/GetImage?image=/Content/Images/default.png"></a></p></div><div class="albumdescription"><p><a>' + title + '</a>(0)</p><p><a>';
                       if (power == 1)
                           $html = $html + '<img src="../../Content/Images/extra/album/friends_only.png" alt="仅好友可见">';
                       else if (power == 0)
                           $html = $html + '<img src="../../Content/Images/extra/album/encrypt.png" alt="隐私">';
                       $('#albumlist').append($html + '</a><a class="edit">编辑</a></p></div></div>');

                       //end call back



                    },
                   error: function () { alert('创建相册失败！'); }
               }); //end of ajax
           }); //end click
       });
      
   </script>
  

